﻿using Coldairarrow.Entity.DTO;
using Coldairarrow.Entity.IT;
using Coldairarrow.Entity.TD;
using Coldairarrow.Util;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Business.IT
{
    public partial interface IIT_LocalMaterialBusiness
    {
        Task<PageResult<IT_LocalMaterial>> GetDataListAsync(PageInput<ConditionDTO> input);
        Task<PageResult<IT_LocalMaterial>> GetDataListByMaterialId(PageInput<ConditionDTO> input);
        Task<IT_LocalMaterial> GetTheDataAsync(string id);
        Task AddDataAsync(IT_LocalMaterial data);
        Task UpdateDataAsync(IT_LocalMaterial data);
        Task DeleteDataAsync(List<string> ids);
        Task<IT_LocalMaterial> GetByLocalMaterial(string local);

        Task<PageResult<IT_LocalMaterialDTO>> GetDataListAsyncDtoList(PageInput<IT_LocalMaterialConditionDTO> input);

        /// <summary>
        /// 查看货位占用量信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        Task<PageResult<AmountOccupied>> GetAmountOccupiedListAsync(PageInput<AmountOccupiedConditionDTO> input);

        /// <summary>
        /// 大屏显示出入库监控
        /// </summary>
        /// <returns>出入库监控</returns>
        Task<List<IT_LocalMaterialOutInStatusDTO>> GetOutInStatus(int Days);
        /// <summary>
        /// PDA扫码获取货区货架货位
        /// </summary>
        /// <param name="locationQrCode">货位二维码</param>
        /// <param name="materialId">物料ID</param>
        /// <returns></returns>
        Task<List<IT_LocalMaterialDTO>> GetPDADataListAsyncDtoList(string locationQrCode, string materialId);

        /// <summary>
        /// 导出库存报表集合
        /// </summary>
        /// <returns></returns>
        Task<List<IT_LocalMaterialDTO>> GetDataListAsynclist();

        /// <summary>
        /// 期初汇算结存数据
        /// </summary>
        /// <returns></returns>
        Task GetStartInventoryBalanceAsync();

        /// <summary>
        /// 上月结存
        /// </summary>
        /// <returns></returns>
        Task GetLastMonthBalanceAsync();

        /// <summary>
        /// 获取库存结存信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        Task<PageResult<MaterialBalance>> GetMaterialBalanceListAsync(PageInput<MaterialBalanceConditionDTO> input);

        /// <summary>
        /// 库存结存信息导出
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        Task<List<MaterialBalance>> GetMaterialBalanceExcelAsync(MaterialBalanceConditionDTO input);

        /// <summary>
        /// 获取结存年份
        /// </summary>
        /// <returns></returns>
        Task<List<string>> GetYearAsync();

        /// <summary>
        /// 获取年月下的月分结存信息
        /// </summary>
        /// <param name="year">年份</param>
        /// <returns></returns>
        Task<List<YearMonthDTO>> GetYearMonthBalanceAsync(string year);

        /// <summary>
        /// 获取结存详情
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        Task<PageResult<MaterialBalance>> GetYearMonthBalanceListAsync(PageInput<BalanceConditionDTO> input);

        /// <summary>
        /// 结存回滚
        /// </summary>
        /// <param name="yearmonth">年月</param>
        /// <returns></returns>
        Task UpRollBACKAsync(string yearmonth);

        /// <summary>
        /// 本月结存
        /// </summary>
        /// <param name="yearmonth">年月</param>
        /// <returns></returns>
        Task UpBalanceAsync(string yearmonth);

        /// <summary>
        /// 获取总资产统计报表
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        Task<PageResultData<IT_TotalAssetsDto>> GetTotalAssetsList(PageInput<IT_LocalDetailDtolistContionDTO> input);


        Task<PageResultData<PB_ProjectAssets>> ProjectAssetsList(PageInput<IT_LocalDetailDtolistContionDTO> input);

        /// <summary>
        /// 项目报损统计
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        Task<PageResultData<IT_ProjectLosses>> IGetProjectLosses(PageInput<IT_LocalDetailDtolistContionDTO> input);


        #region 重置占用量

        /// <summary>
        /// 重置占用量
        /// </summary>
        /// <returns></returns>
        Task ResettingUsageAsync();

        #endregion


    }


    #region   库存结存

    /// <summary>
    /// 入库model
    /// </summary>
    public class InStorDTO
    {
        /// <summary>
        /// 年
        /// </summary>
        public int? Year { get; set; }

        /// <summary>
        /// 月
        /// </summary>
        public int? Month { get; set; }

        /// <summary>
        /// 入库时间
        /// </summary>
        public DateTime? InStorTime { get; set; }

        /// <summary>
        /// 仓库Id
        /// </summary>
        public string StorId { get; set; }

        /// <summary>
        /// 物料Id
        /// </summary>
        public string MaterialId { get; set; }

        /// <summary>
        /// 入库数量
        /// </summary>
        public Double? Num { get; set; }

    }

    /// <summary>
    /// 出库model
    /// </summary>
    public class OutStorDTO
    {

        /// <summary>
        /// 年
        /// </summary>
        public int? Year { get; set; }

        /// <summary>
        /// 月
        /// </summary>
        public int? Month { get; set; }

        /// <summary>
        /// 出库时间
        /// </summary>
        public DateTime? OutTime { get; set; }

        /// <summary>
        /// 仓库Id
        /// </summary>
        public string StorId { get; set; }

        /// <summary>
        /// 物料Id
        /// </summary>
        public string MaterialId { get; set; }

        /// <summary>
        /// 入库数量
        /// </summary>
        public Double? OutNum { get; set; }
    }

    /// <summary>
    /// 仓库物料信息
    /// </summary>
    public class StorMaterialDTO
    {

        /// <summary>
        /// 仓库Id
        /// </summary>
        public string StorId { get; set; }

        /// <summary>
        /// 物料Id
        /// </summary>
        public string MaterialId { get; set; }

    }

    /// <summary>
    /// 库存结存列表
    /// </summary>
    public class MaterialBalanceDTO : IT_MaterialBalance
    {
        /// <summary>
        /// 仓库名称
        /// </summary>
        public string StorName { get; set; }

        /// <summary>
        /// 物料名称
        /// </summary>
        public string MaterialName { get; set; }

        /// <summary>
        /// 物料规格
        /// </summary>
        public string MaterialSpec { get; set; }


    }

    public class MaterialBalanceConditionDTO
    {
        public string Condition { get; set; }
        public string Keyword { get; set; }

        /// <summary>
        /// 年月
        /// </summary>
        public string StartYearMonth { get; set; }

        /// <summary>
        /// 年月
        /// </summary>
        public string EndYearMonth { get; set; }

        /// <summary>
        /// 仓库Id
        /// </summary>
        public string StorId { get; set; }

        /// <summary>
        /// 物料名称
        /// </summary>
        public string MaterialName { get; set; }

        /// <summary>
        /// 是否动销(是否大于零)
        /// </summary>
        public Boolean? MovablePin { get; set; }

        /// <summary>
        /// 当前页
        /// </summary>
        public int pageIndex { get; set; }

        /// <summary>
        /// 每页条数
        /// </summary>
        public int pageRows { get; set; }

    }

    public class MaterialBalanceListDTO
    {
        /// <summary>
        /// 总条数
        /// </summary>
        public int? Count { get; set; }

        /// <summary>
        /// 客户发货统计(明细)
        /// </summary>
        public List<MaterialBalance> MaterialBalance { get; set; }
    }

    /// <summary>
    /// 库存结存汇总
    /// </summary>
    public class MaterialBalance
    {
        /// <summary>
        /// 序号
        /// </summary>
        public int? Rnumber { get; set; }

        /// <summary>
        /// 仓库Id
        /// </summary>
        public string StorId { get; set; }

        /// <summary>
        /// 仓库名称
        /// </summary>
        public string StorName { get; set; }

        /// <summary>
        /// 物料Id
        /// </summary>
        public string MaterialId { get; set; }

        /// <summary>
        /// 物料编码
        /// </summary>
        public string MaterialCode { get; set; }

        /// <summary>
        /// 物料名称
        /// </summary>
        public string MaterialName { get; set; }

        /// <summary>
        /// 物料规格
        /// </summary>
        public string MaterialSpec { get; set; }

        /// <summary>
        /// 期初数量
        /// </summary>
        public double? LastMonth { get; set; }

        /// <summary>
        /// 入库数量
        /// </summary>
        public double? InNums { get; set; }

        /// <summary>
        /// 出库数量
        /// </summary>
        public double? OutNums { get; set; }

        /// <summary>
        /// 结存数量
        /// </summary>
        public double? ThisNums { get; set; }

    }

    public class BalanceConditionDTO
    {
        public string Condition { get; set; }
        public string Keyword { get; set; }

        /// <summary>
        /// 年月
        /// </summary>
        public string yearmonth { get; set; }

        /// <summary>
        /// 仓库Id
        /// </summary>
        public string StorId { get; set; }
    }

    public class YearMonthDTO
    {
        /// <summary>
        /// 年月
        /// </summary>
        public string YearMonth { get; set; }

        /// <summary>
        /// 状态
        /// </summary>
        public int? Status { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public int? TrueOrFalse { get; set; }
    }

    #endregion

    #region 库存占用量查看明细

    public class AmountOccupied
    {
        /// <summary>
        /// 备货单明细
        /// </summary>
        public string Id { get; set; }

        /// <summary>
        /// 备货单Id
        /// </summary>
        public string PickMainId { get; set; }

        /// <summary>
        /// 项目名称
        /// </summary>
        public string BuildingId { get; set; }

        /// <summary>
        /// 发货时间
        /// </summary>
        public DateTime? DeliveryTime { get; set; }

        /// <summary>
        /// 占用量
        /// </summary>
        public double? Nums_R { get; set; }

        /// <summary>
        /// 货位Id
        /// </summary>
        public string LocationId { get; set; }

        /// <summary>
        /// 物料ID
        /// </summary>
        public string MaterialId { get; set; }

        /// <summary>
        /// 物料编码
        /// </summary>
        public string MaterialCode { get; set; }

        /// <summary>
        /// 物料名称
        /// </summary>
        public string MaterialName { get; set; }

        /// <summary>
        /// 物料规格
        /// </summary>
        public string MaterialSpec { get; set; }

        /// <summary>
        /// 成品编码
        /// </summary>
        public string ProductCode { get; set; }

        /// <summary>
        /// 状态：0-待审核，1-已审核，2-开始作业，3-备货完成,
        /// </summary>
        public int? Status { get; set; }


    }

    public class AmountOccupiedConditionDTO
    {
        public string Condition { get; set; }
        public string Keyword { get; set; }

        /// <summary>
        /// 物料Id
        /// </summary>
        public string MaterialId { get; set; }

        /// <summary>
        /// 货位Id
        /// </summary>
        public string LocalId { get; set; }
    }

    #endregion

}